]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
quickSettings: Add SystemIndicator
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 24 Jul 2022 17:29:50 +0000 (19:29 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Aug 2022 16:05:28 +0000 (16:05 +0000)
This serves the exact same purpose as the existing SystemIndicator
class from PanelMenu, except that it exposes a quickSettingsItems
array instead of a menu.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>

js/ui/quickSettings.js

index 340d6a375305957f078a9dfcede66039ac1175c8..0858d69228c4d8d33b8400da9811ce90bd6e0c71 100644 (file)
@@ -1,4 +1,4 @@
-/* exported QuickToggle, QuickSettingsMenu */
+/* exported QuickToggle, QuickSettingsMenu, SystemIndicator */
 const {Atk, Clutter, Gio, GLib, GObject, Pango, St} = imports.gi;
 
 const Main = imports.ui.main;
@@ -268,3 +268,28 @@ var QuickSettingsMenu = class extends PopupMenu.PopupMenu {
             this._grid, item, 'column-span', colSpan);
     }
 };
+
+var SystemIndicator = GObject.registerClass(
+class SystemIndicator extends St.BoxLayout {
+    _init() {
+        super._init({
+            style_class: 'panel-status-indicators-box',
+            reactive: true,
+            visible: false,
+        });
+
+        this.quickSettingsItems = [];
+    }
+
+    _syncIndicatorsVisible() {
+        this.visible = this.get_children().some(a => a.visible);
+    }
+
+    _addIndicator() {
+        const icon = new St.Icon({style_class: 'system-status-icon'});
+        this.add_actor(icon);
+        icon.connect('notify::visible', () => this._syncIndicatorsVisible());
+        this._syncIndicatorsVisible();
+        return icon;
+    }
+});